<html>
<body>
This tests queryCommandState.
<p>
<a href="https://bugs.webkit.org/show_bug.cgi?id=32285">Bug 32285</a>
<br>
<a href="rdar://problem/7442387"> Radar 7442065</a>
</p>
<div id="e" contenteditable="true">
    one
    <div>two</div>
</div>
<ul id="console"></ul>

<script type="text/javascript">

if (window.testRunner) {
    testRunner.dumpAsText();
}
var elem = document.getElementById("e");
var selection = window.getSelection();
selection.collapse(elem, 0);

document.execCommand("SelectAll");
document.execCommand("Bold");
assert(document.queryCommandState("Bold"));
assert(!document.queryCommandState("Italic"));
document.execCommand("Italic");
assert(document.queryCommandState("Bold"));
assert(document.queryCommandState("Italic"));
document.execCommand("Bold", false);
assert(!document.queryCommandState("Bold"));
assert(document.queryCommandState("Italic"));

function log(str) {
    var li = document.createElement("li");
    li.appendChild(document.createTextNode(str));
    var console = document.getElementById("console");
    console.appendChild(li);
}

function assert(bool) {
    if (!bool)
        log("Failure");
    else
        log("Success");
}
</script>
</body>
</html>
